//定义数组存储4个学生的对象
//学生的属性:姓名、年龄、性别、爱好
//要求1:计算出四个学生的平均年龄
//要求2:统计年龄比平均值低的学生有几个?并把他们的所有信息打印出来。
public class A27{
	private String name;
	private int age;
	private char gender;
	private String hobby;
	
	public A27(){}
	public A27(String name,int age,char gender,String hobby){
		this.name = name;
		this.age = age;
		this.gender = gender;
		this.hobby = hobby;
	}
	public String getName(){
		return name;
	}
	public void setName(String name){
		this.name = name;
	}
	public int getAge(){
		return age;
	}
	public void setAge(int age){
		this.age = age;
	}
	public char getGender(){
		return gender;
	}
	public void setGender(char gender){
		this.gender = gender;
	}
	public String getHobby(){
		return hobby;
	}
	public void setHobby(String hobby){
		this.hobby = hobby;
	}
	
	public static void main(String[] args){
		A27[] arr = new A27[4];
		A27 s1 = new A27("花花",25,'女',"玩游戏");
		A27 s2 = new A27("草草",20,'男',"跑步");
		A27 s3 = new A27("明明",29,'男',"乒乓");
		A27 s4 = new A27("红红",22,'女',"羽毛球");
		arr[0] = s1;
		arr[1] = s2;
		arr[2] = s3;
		arr[3] = s4;
		int sum = 0;
		for(int i = 0;i < arr.length;i++){
			sum = sum + arr[i].getAge();
		}
		int average = sum / arr.length;
		System.out.println("平均年龄为" + average + "岁");
		int count = 0;
		for(int i = 0;i < arr.length;i++){
			if(arr[i].getAge() < average){
				count++;
				System.out.println(arr[i].getName() + "," + arr[i].getAge() + "," + arr[i].getGender() + "," + arr[i].getHobby());
			}
		}
		System.out.println("年龄比平均值低的同学有" + count + "个");
	}
	
	
	
}